<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    hostname: new URL('http://yoursite.com').hostname,
    root: '/',
    scheme: 'Pisces',
    version: '7.7.1',
    exturl: false,
    sidebar: {"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},
    copycode: {"enable":false,"show_result":false,"style":null},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":false},
    bookmark: {"enable":false,"color":"#222","save":"auto"},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    comments: {"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},
    algolia: {
      appID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: '',
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}
  };
</script>

  <meta name="description" content="飞行模式切换IP123456789function 打开飞行模式() &amp;#123;  &#x2F;&#x2F; 打开飞行模式  new Shell().exec(&quot;su -c &#39;settings put global airplane_mode_on 1; am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true&#39;&quot;)&amp;#125;;func">
<meta property="og:type" content="article">
<meta property="og:title" content="脚本&#x2F;Auto-js零散例子">
<meta property="og:url" content="http://yoursite.com/2020/03/04/%E8%84%9A%E6%9C%AC/Auto-js%E9%9B%B6%E6%95%A3%E4%BE%8B%E5%AD%90/index.html">
<meta property="og:site_name" content="unltra">
<meta property="og:description" content="飞行模式切换IP123456789function 打开飞行模式() &amp;#123;  &#x2F;&#x2F; 打开飞行模式  new Shell().exec(&quot;su -c &#39;settings put global airplane_mode_on 1; am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true&#39;&quot;)&amp;#125;;func">
<meta property="og:locale" content="en_US">
<meta property="article:published_time" content="2020-03-04T14:18:11.371Z">
<meta property="article:modified_time" content="2020-02-02T07:06:59.000Z">
<meta property="article:author" content="unltra">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://yoursite.com/2020/03/04/%E8%84%9A%E6%9C%AC/Auto-js%E9%9B%B6%E6%95%A3%E4%BE%8B%E5%AD%90/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true
  };
</script>

  <title>脚本/Auto-js零散例子 | unltra</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-meta">

    <div>
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">unltra</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
  </div>

  <div class="site-nav-toggle">
    <div class="toggle" aria-label="Toggle navigation bar">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>Home</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>Archives</a>

  </li>
  </ul>

</nav>
</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content">
            

  <div class="posts-expand">
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block " lang="en">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2020/03/04/%E8%84%9A%E6%9C%AC/Auto-js%E9%9B%B6%E6%95%A3%E4%BE%8B%E5%AD%90/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="https://s2.ax1x.com/2020/02/04/1BYxFx.jpg">
      <meta itemprop="name" content="unltra">
      <meta itemprop="description" content="unltra-blog">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="unltra">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          脚本/Auto-js零散例子
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">Posted on</span>

              <time title="Created: 2020-03-04 22:18:11" itemprop="dateCreated datePublished" datetime="2020-03-04T22:18:11+08:00">2020-03-04</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">Edited on</span>
                <time title="Modified: 2020-02-02 15:06:59" itemprop="dateModified" datetime="2020-02-02T15:06:59+08:00">2020-02-02</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h2 id="飞行模式切换IP"><a href="#飞行模式切换IP" class="headerlink" title="飞行模式切换IP"></a>飞行模式切换IP</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> 打开飞行模式(<span class="params"></span>) </span>&#123;</span><br><span class="line">  <span class="comment">// 打开飞行模式</span></span><br><span class="line">  <span class="keyword">new</span> Shell().exec(<span class="string">"su -c 'settings put global airplane_mode_on 1; am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true'"</span>)</span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">function</span> 关闭飞行模式(<span class="params"></span>) </span>&#123;</span><br><span class="line">  <span class="comment">//关闭飞行模式</span></span><br><span class="line">  <span class="keyword">new</span> Shell().exec(<span class="string">"su -c 'settings put global airplane_mode_on 0; am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false'"</span>)</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>

<h2 id="点击指定区域"><a href="#点击指定区域" class="headerlink" title="点击指定区域"></a>点击指定区域</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">while</span> (<span class="literal">true</span>) &#123;</span><br><span class="line"> click(<span class="number">500</span>, <span class="number">380</span>);</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">//或者用</span></span><br><span class="line"><span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; <span class="number">7</span>; i++) &#123;</span><br><span class="line">	click(<span class="number">500</span>, <span class="number">380</span>);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>


<h2 id="自动打开网址"><a href="#自动打开网址" class="headerlink" title="自动打开网址"></a>自动打开网址</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"Auto"</span></span><br><span class="line">app.openUrl(<span class="string">"http://chapai.act.qq.com/ph2"</span>);</span><br></pre></td></tr></table></figure>



<h2 id="微信轰炸机"><a href="#微信轰炸机" class="headerlink" title="微信轰炸机"></a>微信轰炸机</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="string">"auto"</span>;</span><br><span class="line"><span class="comment">//进入短信发送信息界面，自动进行轰炸</span></span><br><span class="line"><span class="comment">//自行更改需要发送的内容</span></span><br><span class="line"><span class="comment">//土豪专用轰炸机</span></span><br><span class="line">launchApp(<span class="string">"短信"</span>);</span><br><span class="line"></span><br><span class="line">waitForPackage(<span class="string">"com.android.mms"</span>);</span><br><span class="line">toast(<span class="string">"轰炸机已准备"</span>);</span><br><span class="line"></span><br><span class="line"><span class="keyword">while</span>(<span class="literal">true</span>)&#123;</span><br><span class="line">	</span><br><span class="line">	setText(<span class="string">"你好世界！"</span>);</span><br><span class="line">id(<span class="string">"send_button"</span>).click();</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="防检测按键脚本（范围选点）"><a href="#防检测按键脚本（范围选点）" class="headerlink" title="防检测按键脚本（范围选点）"></a>防检测按键脚本（范围选点）</h2><p>random（X，Y）是数值区间，<br>调出手机指针位置后可以找出适合的区间<br>脚本例子:</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"auto"</span>;</span><br><span class="line">launchApp(<span class="string">"appname"</span>)</span><br><span class="line">sleep(<span class="number">1000</span>)</span><br><span class="line">click(random(<span class="number">60</span>, <span class="number">1000</span>), random(<span class="number">60</span>, <span class="number">1660</span>))</span><br><span class="line">sleep(<span class="number">500</span>);</span><br><span class="line">click(random(<span class="number">60</span>, <span class="number">1000</span>), random(<span class="number">60</span>, <span class="number">1660</span>))</span><br><span class="line">sleep(<span class="number">500</span>);</span><br><span class="line">click(random(<span class="number">870</span>, <span class="number">1030</span>), random(<span class="number">130</span>, <span class="number">400</span>))</span><br></pre></td></tr></table></figure>

<h2 id="无限每隔10毫秒点击手机屏幕任意位置"><a href="#无限每隔10毫秒点击手机屏幕任意位置" class="headerlink" title="无限每隔10毫秒点击手机屏幕任意位置"></a>无限每隔10毫秒点击手机屏幕任意位置</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">auto();</span><br><span class="line"><span class="built_in">console</span>.show();</span><br><span class="line"><span class="built_in">console</span>.info(<span class="string">"按音量上键开始，按音量下键结束"</span>);</span><br><span class="line">events.observeKey();</span><br><span class="line"><span class="comment">//按音量上键结束</span></span><br><span class="line">events.onKeyDown(<span class="string">"volume_down"</span>, <span class="function"><span class="keyword">function</span>(<span class="params">event</span>)</span>&#123;</span><br><span class="line">	threads.shutDownAll();</span><br><span class="line"><span class="built_in">console</span>.info(<span class="string">"已结束"</span>);</span><br><span class="line">exit();</span><br><span class="line">&#125;);</span><br><span class="line"></span><br><span class="line">events.onKeyDown(<span class="string">"volume_up"</span>, <span class="function"><span class="keyword">function</span>(<span class="params">event</span>)</span>&#123;</span><br><span class="line">	threads.start(<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">	<span class="comment">//无限每隔10ms点击屏幕任意位置一次</span></span><br><span class="line"><span class="keyword">while</span>(<span class="literal">true</span>)&#123;</span><br><span class="line">	<span class="keyword">var</span> x = random(<span class="number">0</span>, device.width);</span><br><span class="line"><span class="keyword">var</span> y = random(<span class="number">0</span>, device.height);</span><br><span class="line">click(x, y);</span><br><span class="line"><span class="built_in">console</span>.log(<span class="string">"(%d, %d)"</span>, x, y);</span><br><span class="line">sleep(<span class="number">1000</span>);</span><br><span class="line">&#125;</span><br><span class="line">&#125;);</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>

<h2 id="屏幕解锁"><a href="#屏幕解锁" class="headerlink" title="屏幕解锁"></a>屏幕解锁</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line">sleep(<span class="number">5000</span>)<span class="comment">//设定时间</span></span><br><span class="line"><span class="comment">//////////唤醒手机///////////</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/*判断屏幕锁定，解锁屏幕（数字密码）*/</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> (!device.isScreenOn()) &#123;<span class="comment">//息屏状态将屏幕唤醒</span></span><br><span class="line">	</span><br><span class="line">	device.wakeUp();<span class="comment">//唤醒设备</span></span><br><span class="line"></span><br><span class="line">sleep(<span class="number">1000</span>); <span class="comment">// 等待屏幕亮起</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//miui锁屏滑动不能唤出密码输入 通过下拉通知栏点击时间进入密码解锁</span></span><br><span class="line"></span><br><span class="line">swipe(<span class="number">500</span>, <span class="number">30</span>, <span class="number">500</span>, <span class="number">1000</span>, <span class="number">300</span>);</span><br><span class="line"></span><br><span class="line">sleep(<span class="number">400</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">//点击时间</span></span><br><span class="line"></span><br><span class="line">click(<span class="number">100</span>, <span class="number">120</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">//解锁 密码1234</span></span><br><span class="line"></span><br><span class="line">desc(<span class="number">1</span>).findOne().click();</span><br><span class="line"></span><br><span class="line">desc(<span class="number">2</span>).findOne().click();</span><br><span class="line"></span><br><span class="line">desc(<span class="number">3</span>).findOne().click();</span><br><span class="line"></span><br><span class="line">desc(<span class="number">4</span>).findOne().click();</span><br><span class="line"></span><br><span class="line"><span class="comment">//等待解锁完成，返回并退出</span></span><br><span class="line"></span><br><span class="line">back();</span><br><span class="line">exit()</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="抖音弹窗处理"><a href="#抖音弹窗处理" class="headerlink" title="抖音弹窗处理"></a>抖音弹窗处理</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//监听弹窗事件(异常处理)</span></span><br><span class="line">threads.start(<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    <span class="keyword">while</span>(<span class="literal">true</span>)&#123;</span><br><span class="line">        sleep(<span class="number">1200</span>);</span><br><span class="line">        <span class="keyword">if</span>(text(<span class="string">'发现通讯录好友'</span>).exists())&#123;</span><br><span class="line">            text(<span class="string">'取消'</span>).click();</span><br><span class="line">        &#125;;</span><br><span class="line">    &#125;;</span><br><span class="line">    &#125;);</span><br></pre></td></tr></table></figure>

<h2 id="百度手机分辨率"><a href="#百度手机分辨率" class="headerlink" title="百度手机分辨率"></a>百度手机分辨率</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line">log(<span class="string">"脚本有时测得分辨率不对 导致用户无法使用 可以用此方法"</span>);</span><br><span class="line"><span class="keyword">var</span> 正确的分辨率高=百度手机分辨率();</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">function</span> 百度手机分辨率(<span class="params"></span>)</span>&#123;</span><br><span class="line">    <span class="keyword">var</span> fblheight;</span><br><span class="line">    <span class="keyword">var</span> mmm2=<span class="string">"https://www.so.com/s?q="</span>+device.device+<span class="string">"+分辨率"</span>;</span><br><span class="line">    thread1=threads.start(<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;  </span><br><span class="line">        log(<span class="string">"百度手机分辨率 开始"</span>);</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            <span class="keyword">var</span> res = http.get(mmm2);</span><br><span class="line">            <span class="keyword">if</span>(res.statusCode == <span class="number">200</span>)&#123;</span><br><span class="line">                log(<span class="string">"网页打开成功..."</span>);</span><br><span class="line">                <span class="keyword">var</span> httpstr = res.body.string();</span><br><span class="line">                <span class="keyword">var</span> sousuostr=<span class="string">"x"</span>+device.width;</span><br><span class="line">                <span class="keyword">var</span> index = httpstr.indexOf(sousuostr);</span><br><span class="line">                <span class="keyword">if</span>(index&gt;<span class="number">0</span>)&#123;</span><br><span class="line">                    fblheight = <span class="built_in">parseInt</span>(httpstr.substring(index<span class="number">-4</span>,index));</span><br><span class="line">                    log(<span class="string">"百度成功 分辨率高为："</span>+fblheight);</span><br><span class="line">                &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">                    fblheight=<span class="string">"百度失败"</span>;</span><br><span class="line">                    log(<span class="string">"没有检索到分辨率信息"</span>);</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125; <span class="keyword">catch</span> (error) &#123;</span><br><span class="line">            log(<span class="string">"百度手机分辨率 异常!!!"</span>);</span><br><span class="line">            fblheight=<span class="string">"查找异常"</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        log(<span class="string">"百度手机分辨率 结束"</span>);</span><br><span class="line">    &#125;);</span><br><span class="line">    thread1.join(<span class="number">2000</span>);</span><br><span class="line">    thread1.interrupt();</span><br><span class="line">    <span class="keyword">return</span> fblheight;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">log(<span class="string">"正确的分辨率高:"</span>+正确的分辨率高);</span><br><span class="line">log(<span class="string">"脚本测得分辨率高:"</span>+device.height);</span><br></pre></td></tr></table></figure>

<h2 id="禁止脚本多次运行"><a href="#禁止脚本多次运行" class="headerlink" title="禁止脚本多次运行"></a>禁止脚本多次运行</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment"> * Author:TimeOut</span></span><br><span class="line"><span class="comment"> * Date: 2018.12.18</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"> </span><br><span class="line"> <span class="comment">//获取当前所运行的脚本</span></span><br><span class="line"><span class="keyword">var</span> list = engines.all();</span><br><span class="line"><span class="comment">//双循环比较</span></span><br><span class="line"><span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; list.length; i++) &#123;</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">var</span> j = i + <span class="number">1</span>; j &lt; list.length; j++) &#123;</span><br><span class="line">       <span class="comment">//比较是否只有一个运行</span></span><br><span class="line">        <span class="keyword">if</span> (list[i].getSource().toString() == list[j].getSource().toString()) &#123;</span><br><span class="line">            <span class="comment">//停止二次运行的脚本</span></span><br><span class="line">            list[j].forceStop();</span><br><span class="line">        &#125;;</span><br><span class="line">    &#125;;</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>

<h2 id="Http代理-讯代理动态转发示例"><a href="#Http代理-讯代理动态转发示例" class="headerlink" title="[Http代理] 讯代理动态转发示例"></a>[Http代理] 讯代理动态转发示例</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/** </span></span><br><span class="line"><span class="comment"> * 使用时传入url和端口即可 </span></span><br><span class="line"><span class="comment"> * 例如: httpProxy("forward.xdaili.cn", 80);</span></span><br><span class="line"><span class="comment"> *   此函数生效后,在此函数后的所有 Http 请求都会通过该代理去完成</span></span><br><span class="line"><span class="comment"> *  <span class="doctag">@param <span class="type">&#123;string&#125;</span> </span>url </span></span><br><span class="line"><span class="comment"> *  <span class="doctag">@param <span class="type">&#123;int&#125;</span> </span>prot </span></span><br><span class="line"><span class="comment"> * */</span></span><br><span class="line"> <span class="function"><span class="keyword">function</span> <span class="title">httpProxy</span>(<span class="params">url, prot</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> <span class="built_in">Proxy</span> = java.net.Proxy;</span><br><span class="line">    <span class="keyword">var</span> InetSocketAddress = java.net.InetSocketAddress;</span><br><span class="line">    <span class="keyword">var</span> okhttp = <span class="keyword">new</span> Packages.okhttp3.OkHttpClient.Builder().proxy(<span class="keyword">new</span> <span class="built_in">Proxy</span>(<span class="built_in">Proxy</span>.Type.HTTP, <span class="keyword">new</span> InetSocketAddress(url, prot)));</span><br><span class="line">    http.__okhttp__.muteClient(okhttp);</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/** </span></span><br><span class="line"><span class="comment"> * 以下是讯代理的 动态转发 请求示例 </span></span><br><span class="line"><span class="comment"> * 讯代理官方网站: http://www.xdaili.cn </span></span><br><span class="line"><span class="comment"> * 20元 10万次 请求 </span></span><br><span class="line"><span class="comment"> * */</span></span><br><span class="line"> <span class="keyword">var</span> orderNo = <span class="string">""</span>; <span class="comment">//动态转发的订单号 </span></span><br><span class="line"><span class="keyword">var</span> secret = <span class="string">""</span>; <span class="comment">//讯代理的secret,个人中心查看 </span></span><br><span class="line"><span class="keyword">var</span> getMd5 = http.get(<span class="string">'https://script.iqqclub.com/md5.js'</span>);</span><br><span class="line"><span class="built_in">eval</span>(getMd5.body.string());</span><br><span class="line">httpProxy(<span class="string">"forward.xdaili.cn"</span>, <span class="number">80</span>);</span><br><span class="line"><span class="keyword">var</span> html = http.get(<span class="string">"http://www.diaoyu.com"</span>, getHeaders());</span><br><span class="line">log(html.body.string());</span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getHeaders</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> timestamp = <span class="built_in">Math</span>.round(<span class="keyword">new</span> <span class="built_in">Date</span>() / <span class="number">1000</span>);</span><br><span class="line">    <span class="keyword">var</span> planText = <span class="string">"orderno="</span> + orderNo + <span class="string">",secret="</span> + secret + <span class="string">",timestamp="</span> + timestamp;</span><br><span class="line">    <span class="keyword">var</span> sign = hex_md5(planText).toLocaleUpperCase(); <span class="comment">//将拼接的字符串MD5后,转换成大写 </span></span><br><span class="line">    <span class="keyword">var</span> header = &#123;</span><br><span class="line">        headers: &#123; <span class="string">'Proxy-Authorization'</span>: <span class="string">'sign='</span> + sign + <span class="string">'&amp;orderno='</span> + orderNo + <span class="string">'&amp;timestamp='</span> + timestamp, &#125;</span><br><span class="line">    &#125;;</span><br><span class="line">    <span class="keyword">return</span> header;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="Http代理-讯代理优质代理示例"><a href="#Http代理-讯代理优质代理示例" class="headerlink" title="[Http代理]讯代理优质代理示例"></a>[Http代理]讯代理优质代理示例</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/** * 讯代理 优质代理 示例 * </span></span><br><span class="line"><span class="comment"> * 不支持多线程获取 * </span></span><br><span class="line"><span class="comment"> * 脚本中的订单 有效日期截止到: 2018-10-15 15:28 过期后将不可用 * </span></span><br><span class="line"><span class="comment"> * 讯代理官方网站: http://www.xdaili.cn</span></span><br><span class="line"><span class="comment"> * */</span></span><br><span class="line"> <span class="keyword">var</span> spiderId = <span class="string">"7ab204de5b7e403caada6398f29c2831"</span>; <span class="comment">//spiderId </span></span><br><span class="line"><span class="keyword">var</span> orderNo = <span class="string">"YZ20188145457DGCJTP"</span>; <span class="comment">//订单号 </span></span><br><span class="line"><span class="keyword">var</span> getIp_api = http.get(<span class="string">'http://pv.sohu.com/cityjson?ie=utf-8'</span>);</span><br><span class="line"><span class="keyword">var</span> InetIP = getIp_api.body.string();</span><br><span class="line"><span class="built_in">eval</span>(InetIP);</span><br><span class="line">log(<span class="string">"使用代理前的外网IP:"</span> + returnCitySN.cip);</span><br><span class="line"><span class="keyword">var</span> xdailiUrl = <span class="string">"http://api.xdaili.cn/xdaili-api//greatRecharge/getGreatIp?spiderId="</span> + spiderId + <span class="string">"&amp;orderno="</span> + orderNo + <span class="string">"&amp;returnType=2&amp;count=1"</span>;</span><br><span class="line"><span class="keyword">for</span> (<span class="keyword">let</span> i = <span class="number">0</span>; i &lt; <span class="number">3</span>; i++) &#123;</span><br><span class="line">    <span class="keyword">try</span> &#123;</span><br><span class="line">        <span class="keyword">var</span> getProxy_json = http.get(xdailiUrl).body.json();</span><br><span class="line">        <span class="keyword">if</span> (getProxy_json.ERRORCODE == <span class="string">"10036"</span> || getProxy_json.ERRORCODE == <span class="string">"10038"</span> || getProxy_json.ERRORCODE == <span class="string">"10055"</span>) &#123;</span><br><span class="line">            <span class="keyword">throw</span> &#123;</span><br><span class="line">                <span class="string">"code"</span>: <span class="string">"-1"</span>,</span><br><span class="line">                <span class="string">"msg"</span>: <span class="string">"提取速度过快"</span></span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span> (getProxy_json.ERRORCODE == <span class="string">"10036"</span>) &#123;</span><br><span class="line">            <span class="keyword">throw</span> &#123;</span><br><span class="line">                <span class="string">"code"</span>: <span class="string">"-2"</span>,</span><br><span class="line">                <span class="string">"msg"</span>: <span class="string">"提取次数已达上限"</span></span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125; <span class="keyword">catch</span> (e) &#123;</span><br><span class="line">        <span class="keyword">if</span> (e.code == <span class="string">"-1"</span>) &#123;</span><br><span class="line">            log(e.msg);</span><br><span class="line">            sleep(<span class="number">5000</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span> (e.code == <span class="string">"-2"</span>) &#123;</span><br><span class="line">            log(e.msg);</span><br><span class="line">            exit();</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span> (i == <span class="number">2</span>) &#123; <span class="comment">//运行3次后,没有拿到IP和端口 程序结束 log("发生了未知错误,请检查网络..."); </span></span><br><span class="line">            exit();</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">//log(getProxy_json); </span></span><br><span class="line"><span class="keyword">var</span> xdaili_proxyIP = getProxy_json.RESULT[<span class="number">0</span>].ip;</span><br><span class="line"><span class="keyword">var</span> xdaili_proxyPort = <span class="built_in">parseInt</span>(getProxy_json.RESULT[<span class="number">0</span>].port); <span class="comment">//log(xdaili_proxyIP+":"+xdaili_proxyPort); </span></span><br><span class="line">httpProxy(xdaili_proxyIP, xdaili_proxyPort);</span><br><span class="line"><span class="keyword">var</span> getIp_api = http.get(<span class="string">'http://pv.sohu.com/cityjson?ie=utf-8'</span>);</span><br><span class="line"><span class="keyword">var</span> InetIP = getIp_api.body.string();</span><br><span class="line"><span class="built_in">eval</span>(InetIP);</span><br><span class="line">log(<span class="string">"使用代理后的外网IP:"</span> + returnCitySN.cip);</span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">httpProxy</span>(<span class="params">url, prot</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> <span class="built_in">Proxy</span> = java.net.Proxy;</span><br><span class="line">    <span class="keyword">var</span> InetSocketAddress = java.net.InetSocketAddress;</span><br><span class="line">    <span class="keyword">var</span> okhttp = <span class="keyword">new</span> Packages.okhttp3.OkHttpClient.Builder().proxy(<span class="keyword">new</span> <span class="built_in">Proxy</span>(<span class="built_in">Proxy</span>.Type.HTTP, <span class="keyword">new</span> InetSocketAddress(url, prot)));</span><br><span class="line">    http.__okhttp__.muteClient(okhttp);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="获取指定应用的版本号"><a href="#获取指定应用的版本号" class="headerlink" title="获取指定应用的版本号"></a>获取指定应用的版本号</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment">* 获取指定应用的版本号</span></span><br><span class="line"><span class="comment">* @param &#123;string&#125; packageName 应用包名</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getPackageVersion</span>(<span class="params">packageName</span>) </span>&#123;</span><br><span class="line">    importPackage(android.content);</span><br><span class="line">    <span class="keyword">var</span> pckMan = context.getPackageManager();</span><br><span class="line">    <span class="keyword">var</span> packageInfo = pckMan.getPackageInfo(packageName, <span class="number">0</span>);</span><br><span class="line">    <span class="keyword">return</span> packageInfo.versionName;</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
<h2 id="停止APP"><a href="#停止APP" class="headerlink" title="停止APP"></a>停止APP</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 停止APP</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">killApp</span>(<span class="params">packageName</span>) </span>&#123;</span><br><span class="line">    shell(<span class="string">'am force-stop '</span> + packageName, <span class="literal">true</span>);</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
<h2 id="卸载APP"><a href="#卸载APP" class="headerlink" title="卸载APP"></a>卸载APP</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 卸载APP</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">uninstallApp</span>(<span class="params">packageName</span>) </span>&#123;</span><br><span class="line">    shell(<span class="string">"pm uninstall "</span> + packageName, <span class="literal">true</span>)</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
<h2 id="清除App数据"><a href="#清除App数据" class="headerlink" title="清除App数据"></a>清除App数据</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 清除App数据</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">clearApp</span>(<span class="params">packageName</span>) </span>&#123;</span><br><span class="line">    shell(<span class="string">'pm clear '</span> + packageName, <span class="literal">true</span>);</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
<h2 id="卸载最新安装的app"><a href="#卸载最新安装的app" class="headerlink" title="卸载最新安装的app"></a>卸载最新安装的app</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 卸载最新安装的app</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">uninstallAppLast</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> pm = context.getPackageManager()</span><br><span class="line">    <span class="keyword">var</span> appList = pm.getInstalledApplications(<span class="number">0</span>)</span><br><span class="line">    <span class="keyword">var</span> appInfoList = []</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">let</span> i = <span class="number">0</span>; i &lt; appList.size(); i++) &#123;</span><br><span class="line">        <span class="keyword">var</span> app = appList.get(i)</span><br><span class="line">        <span class="keyword">var</span> appInfo = &#123;</span><br><span class="line">            appName: app.loadLabel(pm),</span><br><span class="line">            packageName: app.packageName,</span><br><span class="line">            isSystemApp: app.isSystemApp(),</span><br><span class="line">            firstInstallTime: pm.getPackageInfo(app.packageName, <span class="number">0</span>).firstInstallTime</span><br><span class="line">        &#125;</span><br><span class="line">        appInfoList.push(appInfo)</span><br><span class="line">        </span><br><span class="line">    &#125;</span><br><span class="line">    appInfoList.sort(<span class="function">(<span class="params">a, b</span>) =&gt;</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> b.firstInstallTime - a.firstInstallTime</span><br><span class="line">    &#125;)</span><br><span class="line">    log(<span class="string">'最新安装的app是=%j'</span>, appInfoList[<span class="number">0</span>])</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">var</span> packageName = appInfoList[<span class="number">0</span>].packageName</span><br><span class="line">    shell(<span class="string">"pm uninstall "</span> + packageName, <span class="literal">true</span>)</span><br><span class="line">    <span class="keyword">return</span> appInfoList[<span class="number">0</span>].appName</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
<h2 id="清除最新安装的APP数据"><a href="#清除最新安装的APP数据" class="headerlink" title="清除最新安装的APP数据"></a>清除最新安装的APP数据</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 清除最新安装的APP数据</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">clearAppLast</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> pm = context.getPackageManager()</span><br><span class="line">    <span class="keyword">var</span> appList = pm.getInstalledApplications(<span class="number">0</span>)</span><br><span class="line">    <span class="keyword">var</span> appInfoList = []</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">let</span> i = <span class="number">0</span>; i &lt; appList.size(); i++) &#123;</span><br><span class="line">        <span class="keyword">var</span> app = appList.get(i)</span><br><span class="line">        <span class="keyword">var</span> appInfo = &#123;</span><br><span class="line">            appName: app.loadLabel(pm),</span><br><span class="line">            packageName: app.packageName,</span><br><span class="line">            isSystemApp: app.isSystemApp(),</span><br><span class="line">            firstInstallTime: pm.getPackageInfo(app.packageName, <span class="number">0</span>).firstInstallTime</span><br><span class="line">        &#125;</span><br><span class="line">        appInfoList.push(appInfo)</span><br><span class="line">        </span><br><span class="line">    &#125;</span><br><span class="line">    appInfoList.sort(<span class="function">(<span class="params">a, b</span>) =&gt;</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> b.firstInstallTime - a.firstInstallTime</span><br><span class="line">    &#125;)</span><br><span class="line">    log(<span class="string">'最新安装的app是=%j'</span>, appInfoList[<span class="number">0</span>])</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">var</span> packageName = appInfoList[<span class="number">0</span>].packageName</span><br><span class="line">    shell(<span class="string">'pm clear '</span> + packageName, <span class="literal">true</span>);</span><br><span class="line">    <span class="keyword">return</span> appInfoList[<span class="number">0</span>].appName</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
<h2 id="停止最新安装的APP"><a href="#停止最新安装的APP" class="headerlink" title="停止最新安装的APP"></a>停止最新安装的APP</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 停止最新安装的APP</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">killAppLast</span> </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> pm = context.getPackageManager()</span><br><span class="line">    <span class="keyword">var</span> appList = pm.getInstalledApplications(<span class="number">0</span>)</span><br><span class="line">    <span class="keyword">var</span> appInfoList = []</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">let</span> i = <span class="number">0</span>; i &lt; appList.size(); i++) &#123;</span><br><span class="line">        <span class="keyword">var</span> app = appList.get(i)</span><br><span class="line">        <span class="keyword">var</span> appInfo = &#123;</span><br><span class="line">            appName: app.loadLabel(pm),</span><br><span class="line">            packageName: app.packageName,</span><br><span class="line">            isSystemApp: app.isSystemApp(),</span><br><span class="line">            firstInstallTime: pm.getPackageInfo(app.packageName, <span class="number">0</span>).firstInstallTime</span><br><span class="line">        &#125;</span><br><span class="line">        appInfoList.push(appInfo)</span><br><span class="line">        </span><br><span class="line">    &#125;</span><br><span class="line">    appInfoList.sort(<span class="function">(<span class="params">a, b</span>) =&gt;</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> b.firstInstallTime - a.firstInstallTime</span><br><span class="line">    &#125;)</span><br><span class="line">    log(<span class="string">'最新安装的app是=%j'</span>, appInfoList[<span class="number">0</span>])</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">var</span> packageName = appInfoList[<span class="number">0</span>].packageName</span><br><span class="line">    shell(<span class="string">'am force-stop '</span> + packageName, <span class="literal">true</span>);</span><br><span class="line">    <span class="keyword">return</span> appInfoList[<span class="number">0</span>].appName</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
<h2 id="启动最新安装的APP"><a href="#启动最新安装的APP" class="headerlink" title="启动最新安装的APP"></a>启动最新安装的APP</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 启动最新安装的APP</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">launchAppLast</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> pm = context.getPackageManager()</span><br><span class="line">    <span class="keyword">var</span> appList = pm.getInstalledApplications(<span class="number">0</span>)</span><br><span class="line">    <span class="keyword">var</span> appInfoList = []</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">let</span> i = <span class="number">0</span>; i &lt; appList.size(); i++) &#123;</span><br><span class="line">        <span class="keyword">var</span> app = appList.get(i)</span><br><span class="line">        <span class="keyword">var</span> appInfo = &#123;</span><br><span class="line">            appName: app.loadLabel(pm),</span><br><span class="line">            packageName: app.packageName,</span><br><span class="line">            isSystemApp: app.isSystemApp(),</span><br><span class="line">            firstInstallTime: pm.getPackageInfo(app.packageName, <span class="number">0</span>).firstInstallTime</span><br><span class="line">        &#125;</span><br><span class="line">        appInfoList.push(appInfo)</span><br><span class="line">        </span><br><span class="line">    &#125;</span><br><span class="line">    appInfoList.sort(<span class="function">(<span class="params">a, b</span>) =&gt;</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> b.firstInstallTime - a.firstInstallTime</span><br><span class="line">    &#125;)</span><br><span class="line">    log(<span class="string">'最新安装的app是=%j'</span>, appInfoList[<span class="number">0</span>])</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">var</span> packageName = appInfoList[<span class="number">0</span>].packageName</span><br><span class="line">    launch(packageName)</span><br><span class="line">    <span class="keyword">return</span> appInfoList[<span class="number">0</span>].appName</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>

<h2 id="获取用户安装的app"><a href="#获取用户安装的app" class="headerlink" title="获取用户安装的app"></a>获取用户安装的app</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getUserAppList</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> pm = context.getPackageManager()</span><br><span class="line">    <span class="keyword">var</span> appList = pm.getInstalledApplications(<span class="number">0</span>)</span><br><span class="line">    <span class="keyword">var</span> appInfoList = []</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">let</span> i = <span class="number">0</span>; i &lt; appList.size(); i++) &#123;</span><br><span class="line">        <span class="keyword">var</span> app = appList.get(i)</span><br><span class="line">        <span class="keyword">var</span> appInfo = &#123;</span><br><span class="line">            appName: app.loadLabel(pm),</span><br><span class="line">            packageName: app.packageName,</span><br><span class="line">            isSystemApp: app.isSystemApp(),</span><br><span class="line">            firstInstallTime: pm.getPackageInfo(app.packageName, <span class="number">0</span>).firstInstallTime</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span> (!app.isSystemApp()) &#123;</span><br><span class="line">            appInfoList.push(appInfo)</span><br><span class="line">        &#125;</span><br><span class="line">        </span><br><span class="line">        log(appInfoList)</span><br><span class="line">    &#125;</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>



<h2 id="失去焦点"><a href="#失去焦点" class="headerlink" title="失去焦点"></a>失去焦点</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 失去焦点</span></span><br><span class="line"><span class="built_in">window</span>.disableFocus();</span><br></pre></td></tr></table></figure>
<h2 id="系统是否ROOT"><a href="#系统是否ROOT" class="headerlink" title="系统是否ROOT"></a>系统是否ROOT</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 系统是否ROOT</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">isRoot</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> r = shell(<span class="string">"ls /system/bin"</span>, <span class="literal">true</span>).result.toString()</span><br><span class="line">    <span class="keyword">if</span> (r.length &gt; <span class="number">50</span>) &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">true</span></span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">false</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>

<h2 id="获取指定应用的版本号-1"><a href="#获取指定应用的版本号-1" class="headerlink" title="获取指定应用的版本号"></a>获取指定应用的版本号</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment">* 获取指定应用的版本号</span></span><br><span class="line"><span class="comment">* @param &#123;string&#125; packageName 应用包名</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getPackageVersion</span>(<span class="params">packageName</span>) </span>&#123;</span><br><span class="line">    importPackage(android.content);</span><br><span class="line">    <span class="keyword">var</span> pckMan = context.getPackageManager();</span><br><span class="line">    <span class="keyword">var</span> packageInfo = pckMan.getPackageInfo(packageName, <span class="number">0</span>);</span><br><span class="line">    <span class="keyword">return</span> packageInfo.versionName;</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>

<h2 id="打开QQ群名片"><a href="#打开QQ群名片" class="headerlink" title="打开QQ群名片"></a>打开QQ群名片</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 打开QQ群名片</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> (<span class="params">qqGroupNum</span>) </span>&#123;</span><br><span class="line">    app.startActivity(&#123;</span><br><span class="line">        action: <span class="string">"android.intent.action.VIEW"</span>,</span><br><span class="line">        data: <span class="string">"mqqapi://card/show_pslcard?card_type=group&amp;uin="</span> + qqGroupNum,</span><br><span class="line">        packageName: <span class="string">"com.tencent.mobileqq"</span>,</span><br><span class="line">    &#125;);</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>

<h2 id="QQ强制聊天"><a href="#QQ强制聊天" class="headerlink" title="QQ强制聊天"></a>QQ强制聊天</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// QQ强制聊天</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">qqChat</span>(<span class="params">qqNum</span>) </span>&#123;</span><br><span class="line">    app.startActivity(&#123;</span><br><span class="line">        action: <span class="string">"android.intent.action.VIEW"</span>,</span><br><span class="line">        data: <span class="string">"mqq://im/chat?chat_type=wpa&amp;version=1&amp;src_type=web&amp;uin="</span> + qqNum,</span><br><span class="line">        packageName: <span class="string">"com.tencent.mobileqq"</span>,</span><br><span class="line">    &#125;);</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
<h2 id="取md5"><a href="#取md5" class="headerlink" title="取md5"></a>取md5</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 取md5</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getMd5</span>(<span class="params">string</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> java.math.BigInteger(<span class="number">1</span>, java.security.MessageDigest.getInstance(<span class="string">"MD5"</span>).digest(java.lang.String(string).getBytes())).toString(<span class="number">16</span>);</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
<h2 id="网络检测"><a href="#网络检测" class="headerlink" title="网络检测"></a>网络检测</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 网络检测</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">internetCheck</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> intent = <span class="keyword">new</span> Intent();</span><br><span class="line">    importClass(android.content.BroadcastReceiver);</span><br><span class="line">    importClass(android.content.ContextWrapper);</span><br><span class="line">    importClass(android.content.IntentFilter);</span><br><span class="line">    importClass(android.net.ConnectivityManager);</span><br><span class="line">    <span class="keyword">var</span> filter = <span class="keyword">new</span> IntentFilter();</span><br><span class="line">    filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);</span><br><span class="line">    <span class="keyword">new</span> ContextWrapper(context).registerReceiver(a = <span class="keyword">new</span> BroadcastReceiver(&#123;</span><br><span class="line">        onReceive: <span class="function"><span class="keyword">function</span> (<span class="params">context, intent</span>) </span>&#123;</span><br><span class="line">            <span class="keyword">var</span> action = intent.getAction();</span><br><span class="line">            <span class="keyword">if</span> (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) &#123;</span><br><span class="line">                <span class="keyword">var</span> mConnectivityManager = context.getSystemService(context.CONNECTIVITY_SERVICE);</span><br><span class="line">                netInfo = mConnectivityManager.getActiveNetworkInfo();</span><br><span class="line">                <span class="keyword">if</span> (netInfo != <span class="literal">null</span> &amp;&amp; netInfo.isAvailable()) &#123;</span><br><span class="line">                	</span><br><span class="line">                    <span class="comment">/////////////网络连接</span></span><br><span class="line">                    <span class="keyword">var</span> name = netInfo.getTypeName();</span><br><span class="line">                    </span><br><span class="line">                    <span class="keyword">if</span> (netInfo.getType() == ConnectivityManager.TYPE_WIFI) &#123;</span><br><span class="line">                        <span class="comment">/////WiFi网络</span></span><br><span class="line">                        toastLog(<span class="string">"WiFi网络"</span>);</span><br><span class="line">                        <span class="keyword">return</span> <span class="string">"WiFi网络"</span></span><br><span class="line">                    &#125; <span class="keyword">else</span> <span class="keyword">if</span> (netInfo.getType() == ConnectivityManager.TYPE_ETHERNET) &#123;</span><br><span class="line">                        <span class="comment">/////有线网络</span></span><br><span class="line">                        toastLog(<span class="string">"有线网络"</span>);</span><br><span class="line">                        <span class="keyword">return</span> <span class="string">"有线网络"</span></span><br><span class="line">                        </span><br><span class="line">                    &#125; <span class="keyword">else</span> <span class="keyword">if</span> (netInfo.getType() == ConnectivityManager.TYPE_MOBILE) &#123;</span><br><span class="line">                        <span class="comment">/////////3g网络</span></span><br><span class="line">                        toastLog(<span class="string">"3g网络"</span>);</span><br><span class="line">                        <span class="keyword">return</span> <span class="string">"3g网络"</span></span><br><span class="line">                        </span><br><span class="line">                    &#125;</span><br><span class="line">                &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                    <span class="comment">////////网络断开</span></span><br><span class="line">                    toastLog(<span class="string">"网络断开"</span>);</span><br><span class="line">                    <span class="keyword">return</span> <span class="string">"网络断开"</span></span><br><span class="line">                    </span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">            </span><br><span class="line">        &#125;</span><br><span class="line">    &#125;), filter);</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>


<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 获取手机ip地理位置</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getAction</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> ip地理位置 = <span class="literal">false</span></span><br><span class="line">    <span class="keyword">var</span> ip地理位置正则 = <span class="regexp">/本机IP:&amp;nbsp;\d&#123;1,3&#125;\.\d&#123;1,3&#125;\.\d&#123;1,3&#125;\.\d&#123;1,3&#125;&lt;\/span&gt;([\s\S]*?)&lt;\/td/</span></span><br><span class="line">    <span class="keyword">var</span> ipUrl = <span class="string">"http://www.baidu.com/s?ie=UTF-8&amp;wd=ip%E5%BD%92%E5%B1%9E%E5%9C%B0%E6%9F%A5%E8%AF%A2"</span></span><br><span class="line">    <span class="keyword">var</span> r = http.get(ipUrl);</span><br><span class="line">    log(<span class="string">"code = "</span> + r.statusCode);</span><br><span class="line">    <span class="keyword">var</span> htmlResult = r.body.string()</span><br><span class="line">    ip地理位置 = ip地理位置正则.exec(htmlResult)</span><br><span class="line">    <span class="keyword">if</span> (ip地理位置) &#123;</span><br><span class="line">        ip地理位置 = ip地理位置正则.exec(ip地理位置)</span><br><span class="line">        ip地理位置 = ip地理位置[<span class="number">1</span>]</span><br><span class="line">        toastLog(ip地理位置)</span><br><span class="line">        <span class="keyword">return</span> ip地理位置</span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">        log(<span class="string">'没有查询到Ip地理位置,脚本停止'</span>)</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">false</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>

<h2 id="自定义位置提示块"><a href="#自定义位置提示块" class="headerlink" title="自定义位置提示块"></a>自定义位置提示块</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//自定义位置提示块</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">toastEx</span>(<span class="params">msg, x, y</span>) </span>&#123;</span><br><span class="line">    importClass(android.widget.Toast);</span><br><span class="line">    importClass(android.view.Gravity);</span><br><span class="line">    <span class="keyword">var</span> toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);</span><br><span class="line">    toast.setGravity(Gravity.TOP | Gravity.LEFT, x, y);</span><br><span class="line">    toast.show();</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>


<h2 id="比较日期大小"><a href="#比较日期大小" class="headerlink" title="比较日期大小"></a>比较日期大小</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="keyword">let</span> begintime = <span class="string">'2019-11-25'</span></span><br><span class="line"><span class="keyword">let</span> endtime = getNowFormatDate()</span><br><span class="line">log(endtime)</span><br><span class="line">log(compareDate(begintime, endtime))</span><br><span class="line"></span><br><span class="line"><span class="comment">// 比较日期大小</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">compareDate</span>(<span class="params">begintime, endtime</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> ((<span class="keyword">new</span> <span class="built_in">Date</span>(begintime.replace(<span class="regexp">/-/g</span>, <span class="string">"\/"</span>))) &lt; (<span class="keyword">new</span> <span class="built_in">Date</span>(endtime.replace(<span class="regexp">/-/g</span>, <span class="string">"\/"</span>))));</span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 获取当前日期2019-11-26</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getNowFormatDate</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> date = <span class="keyword">new</span> <span class="built_in">Date</span>();</span><br><span class="line">    <span class="keyword">var</span> seperator1 = <span class="string">"-"</span>;</span><br><span class="line">    <span class="keyword">var</span> year = date.getFullYear();</span><br><span class="line">    <span class="keyword">var</span> month = date.getMonth() + <span class="number">1</span>;</span><br><span class="line">    <span class="keyword">var</span> strDate = date.getDate();</span><br><span class="line">    <span class="keyword">if</span> (month &gt;= <span class="number">1</span> &amp;&amp; month &lt;= <span class="number">9</span>) &#123;</span><br><span class="line">        month = <span class="string">"0"</span> + month;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">if</span> (strDate &gt;= <span class="number">0</span> &amp;&amp; strDate &lt;= <span class="number">9</span>) &#123;</span><br><span class="line">        strDate = <span class="string">"0"</span> + strDate;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">var</span> currentdate = year + seperator1 + month + seperator1 + strDate;</span><br><span class="line">    <span class="keyword">return</span> currentdate;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

    </div>

    
    
    

      <footer class="post-footer">

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2020/03/04/%E8%84%9A%E6%9C%AC/Auto-js%E8%BD%AF%E4%BB%B6%E5%B7%A5%E5%85%B7%E9%9B%86%E5%90%88/" rel="prev" title="脚本/Auto-js软件工具集合">
      <i class="fa fa-chevron-left"></i> 脚本/Auto-js软件工具集合
    </a></div>
      <div class="post-nav-item">
    <a href="/2020/03/04/%E8%BD%AF%E4%BB%B6%E5%8F%8A%E5%B0%8F%E5%B7%A5%E5%85%B7/81%E7%A7%8D%E7%BD%91%E7%9B%98,%E8%B5%84%E6%BA%90,%E7%A3%81%E9%93%BE%E6%80%BB%E6%9C%89%E4%B8%80%E4%B8%AA%E4%BD%A0%E5%96%9C%E6%AC%A2/" rel="next" title="软件及小工具/81种网盘,资源,磁链总有一个你喜欢">
      软件及小工具/81种网盘,资源,磁链总有一个你喜欢 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  

  </div>


          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let activeClass = CONFIG.comments.activeClass;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          Table of Contents
        </li>
        <li class="sidebar-nav-overview">
          Overview
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#飞行模式切换IP"><span class="nav-number">1.</span> <span class="nav-text">飞行模式切换IP</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#点击指定区域"><span class="nav-number">2.</span> <span class="nav-text">点击指定区域</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#自动打开网址"><span class="nav-number">3.</span> <span class="nav-text">自动打开网址</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#微信轰炸机"><span class="nav-number">4.</span> <span class="nav-text">微信轰炸机</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#防检测按键脚本（范围选点）"><span class="nav-number">5.</span> <span class="nav-text">防检测按键脚本（范围选点）</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#无限每隔10毫秒点击手机屏幕任意位置"><span class="nav-number">6.</span> <span class="nav-text">无限每隔10毫秒点击手机屏幕任意位置</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#屏幕解锁"><span class="nav-number">7.</span> <span class="nav-text">屏幕解锁</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#抖音弹窗处理"><span class="nav-number">8.</span> <span class="nav-text">抖音弹窗处理</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#百度手机分辨率"><span class="nav-number">9.</span> <span class="nav-text">百度手机分辨率</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#禁止脚本多次运行"><span class="nav-number">10.</span> <span class="nav-text">禁止脚本多次运行</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Http代理-讯代理动态转发示例"><span class="nav-number">11.</span> <span class="nav-text">[Http代理] 讯代理动态转发示例</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Http代理-讯代理优质代理示例"><span class="nav-number">12.</span> <span class="nav-text">[Http代理]讯代理优质代理示例</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#获取指定应用的版本号"><span class="nav-number">13.</span> <span class="nav-text">获取指定应用的版本号</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#停止APP"><span class="nav-number">14.</span> <span class="nav-text">停止APP</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#卸载APP"><span class="nav-number">15.</span> <span class="nav-text">卸载APP</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#清除App数据"><span class="nav-number">16.</span> <span class="nav-text">清除App数据</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#卸载最新安装的app"><span class="nav-number">17.</span> <span class="nav-text">卸载最新安装的app</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#清除最新安装的APP数据"><span class="nav-number">18.</span> <span class="nav-text">清除最新安装的APP数据</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#停止最新安装的APP"><span class="nav-number">19.</span> <span class="nav-text">停止最新安装的APP</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#启动最新安装的APP"><span class="nav-number">20.</span> <span class="nav-text">启动最新安装的APP</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#获取用户安装的app"><span class="nav-number">21.</span> <span class="nav-text">获取用户安装的app</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#失去焦点"><span class="nav-number">22.</span> <span class="nav-text">失去焦点</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#系统是否ROOT"><span class="nav-number">23.</span> <span class="nav-text">系统是否ROOT</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#获取指定应用的版本号-1"><span class="nav-number">24.</span> <span class="nav-text">获取指定应用的版本号</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#打开QQ群名片"><span class="nav-number">25.</span> <span class="nav-text">打开QQ群名片</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#QQ强制聊天"><span class="nav-number">26.</span> <span class="nav-text">QQ强制聊天</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#取md5"><span class="nav-number">27.</span> <span class="nav-text">取md5</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#网络检测"><span class="nav-number">28.</span> <span class="nav-text">网络检测</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#自定义位置提示块"><span class="nav-number">29.</span> <span class="nav-text">自定义位置提示块</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#比较日期大小"><span class="nav-number">30.</span> <span class="nav-text">比较日期大小</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="unltra"
      src="https://s2.ax1x.com/2020/02/04/1BYxFx.jpg">
  <p class="site-author-name" itemprop="name">unltra</p>
  <div class="site-description" itemprop="description">unltra-blog</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">9</span>
          <span class="site-state-item-name">posts</span>
        </a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/unltra" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;unltra" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">unltra</span>
</div>
<div style="width:300px;margin:0 auto; padding:0 0;" align="center">
<a target="_blank" href="http://www.beian.miit.gov.cn/" style="display:inline-block;text-decoration:none;height:20px;line-height:20px;">
<p style="float:left;height:20px;line-height:20px;margin: 0px 0px 0px 5px; color:#939393;">浙ICP备17019849号-1</p></a>
</div>
<div style="width:300px;margin:0 auto; padding:0 0;" align="center">
  <a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=33021202000572" style="display:inline-block;text-decoration:none;height:20px;line-height:20px;">
  <img src="https://s2.ax1x.com/2019/12/18/QHme9s.png" style="float:left;"/>
<p style="float:left;height:20px;line-height:20px;margin: 0px 0px 0px 5px; color:#939393;">浙公网安备 33021202000572号</p></a>
</div>
  <div class="powered-by">Powered by <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> v4.2.0
  </div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">Theme – <a href="https://pisces.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Pisces</a> v7.7.1
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
